package com.lagou.controller;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

@Controller
public class ComsumerComponet {

    @Reference
    private HelloService helloService;

    @RequestMapping("sayHello")
    @ResponseBody
    public String sayHello(String name, HttpServletRequest request){
        RpcContext.getContext().setAttachment("ip",request.getRemoteHost());
        return helloService.sayHello(name);
    }

}
